package com.we.tickets.contracts.review;

import io.reactivex.Flowable;
import io.reactivex.functions.Function;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.concurrent.Callable;
import org.web3j.abi.EventEncoder;
import org.web3j.abi.TypeReference;
import org.web3j.abi.datatypes.Address;
import org.web3j.abi.datatypes.Bool;
import org.web3j.abi.datatypes.Event;
import org.web3j.abi.datatypes.Type;
import org.web3j.abi.datatypes.Utf8String;
import org.web3j.abi.datatypes.generated.Uint256;
import org.web3j.crypto.Credentials;
import org.web3j.protocol.Web3j;
import org.web3j.protocol.core.DefaultBlockParameter;
import org.web3j.protocol.core.RemoteCall;
import org.web3j.protocol.core.RemoteFunctionCall;
import org.web3j.protocol.core.methods.request.EthFilter;
import org.web3j.protocol.core.methods.response.BaseEventResponse;
import org.web3j.protocol.core.methods.response.Log;
import org.web3j.protocol.core.methods.response.TransactionReceipt;
import org.web3j.tuples.generated.Tuple5;
import org.web3j.tx.Contract;
import org.web3j.tx.TransactionManager;
import org.web3j.tx.gas.ContractGasProvider;

/**
 * <p>Auto generated code.
 * <p><strong>Do not modify!</strong>
 * <p>Please use the <a href="https://docs.web3j.io/command_line.html">web3j command line tools</a>,
 * or the org.web3j.codegen.SolidityFunctionWrapperGenerator in the
 * <a href="https://github.com/web3j/web3j/tree/master/codegen">codegen module</a> to update.
 *
 * <p>Generated with web3j version 1.4.2.
 */
@SuppressWarnings("rawtypes")
public class ReviewManagement extends Contract {
    public static final String BINARY = "608060405234801561001057600080fd5b5061001a3361001f565b610071565b600480546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b610cbf806100806000396000f3fe608060405234801561001057600080fd5b50600436106100be5760003560e01c80638da5cb5b11610076578063b1ff3a7c1161005b578063b1ff3a7c146101a0578063c4f8c912146101c4578063f2fde38b146101e457600080fd5b80638da5cb5b1461017c57806394cdf85f1461018d57600080fd5b80635e801561116100a75780635e8015611461010b5780636d4657ef14610136578063715018a61461017457600080fd5b80633a65d832146100c35780634ab2fcd8146100d8575b600080fd5b6100d66100d136600461099a565b6101f7565b005b6100f86100e63660046109db565b60026020526000908152604090205481565b6040519081526020015b60405180910390f35b60055461011e906001600160a01b031681565b6040516001600160a01b039091168152602001610102565b6101646101443660046109f4565b600160209081526000928352604080842090915290825290205460ff1681565b6040519015158152602001610102565b6100d661022e565b6004546001600160a01b031661011e565b6100d661019b366004610af3565b610242565b6101b36101ae366004610b75565b6106da565b604051610102959493929190610b97565b6100f86101d23660046109db565b60036020526000908152604090205481565b6100d66101f236600461099a565b6107a3565b6101ff610833565b6005805473ffffffffffffffffffffffffffffffffffffffff19166001600160a01b0392909216919091179055565b610236610833565b610240600061088d565b565b6005546040517f89b89262000000000000000000000000000000000000000000000000000000008152600481018690526001600160a01b0390911690600090819083906389b892629060240160806040518083038186803b1580156102a657600080fd5b505afa1580156102ba573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906102de9190610a24565b50506040517f6352211e000000000000000000000000000000000000000000000000000000008152600481018a9052919350915033906001600160a01b03851690636352211e9060240160206040518083038186803b15801561034057600080fd5b505afa158015610354573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061037891906109be565b6001600160a01b0316146103d35760405162461bcd60e51b815260206004820152600d60248201527f556e617574686572697a65642e0000000000000000000000000000000000000060448201526064015b60405180910390fd5b600082116104235760405162461bcd60e51b815260206004820152601360248201527f4c49464520646f65736e27742065786973742e0000000000000000000000000060448201526064016103ca565b806104705760405162461bcd60e51b815260206004820152600960248201527f4e6f7420757365642e000000000000000000000000000000000000000000000060448201526064016103ca565b6040517f91802d76000000000000000000000000000000000000000000000000000000008152600481018390526000906001600160a01b038516906391802d76906024016101406040518083038186803b1580156104cd57600080fd5b505afa1580156104e1573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906105059190610a71565b5050506000878152600160209081526040808320338452909152902054969750505060ff90941615935061057f925050505760405162461bcd60e51b815260206004820152601a60248201527f596f75206861766520616c72656164792072657669657765642e00000000000060448201526064016103ca565b6040518060a00160405280848152602001336001600160a01b0316815260200188888080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920182905250938552505050602080830189905242604093840152848252818152828220600280835284842054845290825291839020845181558482015160018201805473ffffffffffffffffffffffffffffffffffffffff19166001600160a01b0390921691909117905592840151805161064e9385019291909101906108ec565b50606082015160038201556080909101516004909101556000818152600260205260408120805460019290610684908490610c13565b9091555050600081815260036020526040812080548792906106a7908490610c13565b90915550506000908152600160208181526040808420338552909152909120805460ff1916909117905550505050505050565b600060208181529281526040808220909352908152208054600182015460028301805492936001600160a01b039092169261071490610c39565b80601f016020809104026020016040519081016040528092919081815260200182805461074090610c39565b801561078d5780601f106107625761010080835404028352916020019161078d565b820191906000526020600020905b81548152906001019060200180831161077057829003601f168201915b5050505050908060030154908060040154905085565b6107ab610833565b6001600160a01b0381166108275760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201527f646472657373000000000000000000000000000000000000000000000000000060648201526084016103ca565b6108308161088d565b50565b6004546001600160a01b031633146102405760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016103ca565b600480546001600160a01b0383811673ffffffffffffffffffffffffffffffffffffffff19831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b8280546108f890610c39565b90600052602060002090601f01602090048101928261091a5760008555610960565b82601f1061093357805160ff1916838001178555610960565b82800160010185558215610960579182015b82811115610960578251825591602001919060010190610945565b5061096c929150610970565b5090565b5b8082111561096c5760008155600101610971565b8051801515811461099557600080fd5b919050565b6000602082840312156109ac57600080fd5b81356109b781610c74565b9392505050565b6000602082840312156109d057600080fd5b81516109b781610c74565b6000602082840312156109ed57600080fd5b5035919050565b60008060408385031215610a0757600080fd5b823591506020830135610a1981610c74565b809150509250929050565b60008060008060808587031215610a3a57600080fd5b84519350610a4a60208601610985565b9250610a5860408601610985565b9150610a6660608601610985565b905092959194509250565b6000806000806000806000806000806101408b8d031215610a9157600080fd5b8a519950610aa160208c01610985565b9850610aaf60408c01610985565b975060608b0151965060808b0151955060a08b0151945060c08b0151935060e08b015192506101008b015191506101208b015190509295989b9194979a5092959850565b60008060008060608587031215610b0957600080fd5b84359350602085013567ffffffffffffffff80821115610b2857600080fd5b818701915087601f830112610b3c57600080fd5b813581811115610b4b57600080fd5b886020828501011115610b5d57600080fd5b95986020929092019750949560400135945092505050565b60008060408385031215610b8857600080fd5b50508035926020909101359150565b858152600060206001600160a01b0387168184015260a0604084015285518060a085015260005b81811015610bda5787810183015185820160c001528201610bbe565b81811115610bec57600060c083870101525b5060608401959095525050608081019190915260c0601f909201601f191601019392505050565b60008219821115610c3457634e487b7160e01b600052601160045260246000fd5b500190565b600181811c90821680610c4d57607f821691505b60208210811415610c6e57634e487b7160e01b600052602260045260246000fd5b50919050565b6001600160a01b038116811461083057600080fdfea264697066735822122086c65ea00287a9c971e98d135addd32b342cd377cf2b2a1abce0ce9fdea95bab64736f6c63430008070033";

    public static final String FUNC_EVENTREVIEWERSMAP = "EventReviewersMap";

    public static final String FUNC_EVENTREVIEWSMAP = "EventReviewsMap";

    public static final String FUNC_EVENTREVIEWSNUMMAP = "EventReviewsNumMap";

    public static final String FUNC_EVENTTOTALSCOREMAP = "EventTotalScoreMap";

    public static final String FUNC_TMADD = "TMAdd";

    public static final String FUNC_ADDREVIEW = "addReview";

    public static final String FUNC_OWNER = "owner";

    public static final String FUNC_RENOUNCEOWNERSHIP = "renounceOwnership";

    public static final String FUNC_SETTMADD = "setTMAdd";

    public static final String FUNC_TRANSFEROWNERSHIP = "transferOwnership";

    public static final Event OWNERSHIPTRANSFERRED_EVENT = new Event("OwnershipTransferred",
            Arrays.<TypeReference<?>>asList(new TypeReference<Address>(true) {}, new TypeReference<Address>(true) {}));
    ;

    @Deprecated
    protected ReviewManagement(String contractAddress, Web3j web3j, Credentials credentials, BigInteger gasPrice, BigInteger gasLimit) {
        super(BINARY, contractAddress, web3j, credentials, gasPrice, gasLimit);
    }

    protected ReviewManagement(String contractAddress, Web3j web3j, Credentials credentials, ContractGasProvider contractGasProvider) {
        super(BINARY, contractAddress, web3j, credentials, contractGasProvider);
    }

    @Deprecated
    protected ReviewManagement(String contractAddress, Web3j web3j, TransactionManager transactionManager, BigInteger gasPrice, BigInteger gasLimit) {
        super(BINARY, contractAddress, web3j, transactionManager, gasPrice, gasLimit);
    }

    protected ReviewManagement(String contractAddress, Web3j web3j, TransactionManager transactionManager, ContractGasProvider contractGasProvider) {
        super(BINARY, contractAddress, web3j, transactionManager, contractGasProvider);
    }

    public List<OwnershipTransferredEventResponse> getOwnershipTransferredEvents(TransactionReceipt transactionReceipt) {
        List<Contract.EventValuesWithLog> valueList = extractEventParametersWithLog(OWNERSHIPTRANSFERRED_EVENT, transactionReceipt);
        ArrayList<OwnershipTransferredEventResponse> responses = new ArrayList<OwnershipTransferredEventResponse>(valueList.size());
        for (Contract.EventValuesWithLog eventValues : valueList) {
            OwnershipTransferredEventResponse typedResponse = new OwnershipTransferredEventResponse();
            typedResponse.log = eventValues.getLog();
            typedResponse.previousOwner = (String) eventValues.getIndexedValues().get(0).getValue();
            typedResponse.newOwner = (String) eventValues.getIndexedValues().get(1).getValue();
            responses.add(typedResponse);
        }
        return responses;
    }

    public Flowable<OwnershipTransferredEventResponse> ownershipTransferredEventFlowable(EthFilter filter) {
        return web3j.ethLogFlowable(filter).map(new Function<Log, OwnershipTransferredEventResponse>() {
            @Override
            public OwnershipTransferredEventResponse apply(Log log) {
                Contract.EventValuesWithLog eventValues = extractEventParametersWithLog(OWNERSHIPTRANSFERRED_EVENT, log);
                OwnershipTransferredEventResponse typedResponse = new OwnershipTransferredEventResponse();
                typedResponse.log = log;
                typedResponse.previousOwner = (String) eventValues.getIndexedValues().get(0).getValue();
                typedResponse.newOwner = (String) eventValues.getIndexedValues().get(1).getValue();
                return typedResponse;
            }
        });
    }

    public Flowable<OwnershipTransferredEventResponse> ownershipTransferredEventFlowable(DefaultBlockParameter startBlock, DefaultBlockParameter endBlock) {
        EthFilter filter = new EthFilter(startBlock, endBlock, getContractAddress());
        filter.addSingleTopic(EventEncoder.encode(OWNERSHIPTRANSFERRED_EVENT));
        return ownershipTransferredEventFlowable(filter);
    }

    public RemoteFunctionCall<Boolean> EventReviewersMap(BigInteger param0, String param1) {
        final org.web3j.abi.datatypes.Function function = new org.web3j.abi.datatypes.Function(FUNC_EVENTREVIEWERSMAP,
                Arrays.<Type>asList(new org.web3j.abi.datatypes.generated.Uint256(param0),
                new org.web3j.abi.datatypes.Address(160, param1)),
                Arrays.<TypeReference<?>>asList(new TypeReference<Bool>() {}));
        return executeRemoteCallSingleValueReturn(function, Boolean.class);
    }

    public RemoteFunctionCall<Tuple5<BigInteger, String, String, BigInteger, BigInteger>> EventReviewsMap(BigInteger param0, BigInteger param1) {
        final org.web3j.abi.datatypes.Function function = new org.web3j.abi.datatypes.Function(FUNC_EVENTREVIEWSMAP,
                Arrays.<Type>asList(new org.web3j.abi.datatypes.generated.Uint256(param0),
                new org.web3j.abi.datatypes.generated.Uint256(param1)),
                Arrays.<TypeReference<?>>asList(new TypeReference<Uint256>() {}, new TypeReference<Address>() {}, new TypeReference<Utf8String>() {}, new TypeReference<Uint256>() {}, new TypeReference<Uint256>() {}));
        return new RemoteFunctionCall<Tuple5<BigInteger, String, String, BigInteger, BigInteger>>(function,
                new Callable<Tuple5<BigInteger, String, String, BigInteger, BigInteger>>() {
                    @Override
                    public Tuple5<BigInteger, String, String, BigInteger, BigInteger> call() throws Exception {
                        List<Type> results = executeCallMultipleValueReturn(function);
                        return new Tuple5<BigInteger, String, String, BigInteger, BigInteger>(
                                (BigInteger) results.get(0).getValue(),
                                (String) results.get(1).getValue(),
                                (String) results.get(2).getValue(),
                                (BigInteger) results.get(3).getValue(),
                                (BigInteger) results.get(4).getValue());
                    }
                });
    }

    public RemoteFunctionCall<BigInteger> EventReviewsNumMap(BigInteger param0) {
        final org.web3j.abi.datatypes.Function function = new org.web3j.abi.datatypes.Function(FUNC_EVENTREVIEWSNUMMAP,
                Arrays.<Type>asList(new org.web3j.abi.datatypes.generated.Uint256(param0)),
                Arrays.<TypeReference<?>>asList(new TypeReference<Uint256>() {}));
        return executeRemoteCallSingleValueReturn(function, BigInteger.class);
    }

    public RemoteFunctionCall<BigInteger> EventTotalScoreMap(BigInteger param0) {
        final org.web3j.abi.datatypes.Function function = new org.web3j.abi.datatypes.Function(FUNC_EVENTTOTALSCOREMAP,
                Arrays.<Type>asList(new org.web3j.abi.datatypes.generated.Uint256(param0)),
                Arrays.<TypeReference<?>>asList(new TypeReference<Uint256>() {}));
        return executeRemoteCallSingleValueReturn(function, BigInteger.class);
    }

    public RemoteFunctionCall<String> TMAdd() {
        final org.web3j.abi.datatypes.Function function = new org.web3j.abi.datatypes.Function(FUNC_TMADD,
                Arrays.<Type>asList(),
                Arrays.<TypeReference<?>>asList(new TypeReference<Address>() {}));
        return executeRemoteCallSingleValueReturn(function, String.class);
    }

    public RemoteFunctionCall<TransactionReceipt> addReview(BigInteger LIFEId, String commentURI, BigInteger score) {
        final org.web3j.abi.datatypes.Function function = new org.web3j.abi.datatypes.Function(
                FUNC_ADDREVIEW,
                Arrays.<Type>asList(new org.web3j.abi.datatypes.generated.Uint256(LIFEId),
                new org.web3j.abi.datatypes.Utf8String(commentURI),
                new org.web3j.abi.datatypes.generated.Uint256(score)),
                Collections.<TypeReference<?>>emptyList());
        return executeRemoteCallTransaction(function);
    }

    public RemoteFunctionCall<String> owner() {
        final org.web3j.abi.datatypes.Function function = new org.web3j.abi.datatypes.Function(FUNC_OWNER,
                Arrays.<Type>asList(),
                Arrays.<TypeReference<?>>asList(new TypeReference<Address>() {}));
        return executeRemoteCallSingleValueReturn(function, String.class);
    }

    public RemoteFunctionCall<TransactionReceipt> renounceOwnership() {
        final org.web3j.abi.datatypes.Function function = new org.web3j.abi.datatypes.Function(
                FUNC_RENOUNCEOWNERSHIP,
                Arrays.<Type>asList(),
                Collections.<TypeReference<?>>emptyList());
        return executeRemoteCallTransaction(function);
    }

    public RemoteFunctionCall<TransactionReceipt> setTMAdd(String _TMAdd) {
        final org.web3j.abi.datatypes.Function function = new org.web3j.abi.datatypes.Function(
                FUNC_SETTMADD,
                Arrays.<Type>asList(new org.web3j.abi.datatypes.Address(160, _TMAdd)),
                Collections.<TypeReference<?>>emptyList());
        return executeRemoteCallTransaction(function);
    }

    public RemoteFunctionCall<TransactionReceipt> transferOwnership(String newOwner) {
        final org.web3j.abi.datatypes.Function function = new org.web3j.abi.datatypes.Function(
                FUNC_TRANSFEROWNERSHIP,
                Arrays.<Type>asList(new org.web3j.abi.datatypes.Address(160, newOwner)),
                Collections.<TypeReference<?>>emptyList());
        return executeRemoteCallTransaction(function);
    }

    @Deprecated
    public static ReviewManagement load(String contractAddress, Web3j web3j, Credentials credentials, BigInteger gasPrice, BigInteger gasLimit) {
        return new ReviewManagement(contractAddress, web3j, credentials, gasPrice, gasLimit);
    }

    @Deprecated
    public static ReviewManagement load(String contractAddress, Web3j web3j, TransactionManager transactionManager, BigInteger gasPrice, BigInteger gasLimit) {
        return new ReviewManagement(contractAddress, web3j, transactionManager, gasPrice, gasLimit);
    }

    public static ReviewManagement load(String contractAddress, Web3j web3j, Credentials credentials, ContractGasProvider contractGasProvider) {
        return new ReviewManagement(contractAddress, web3j, credentials, contractGasProvider);
    }

    public static ReviewManagement load(String contractAddress, Web3j web3j, TransactionManager transactionManager, ContractGasProvider contractGasProvider) {
        return new ReviewManagement(contractAddress, web3j, transactionManager, contractGasProvider);
    }

    public static RemoteCall<ReviewManagement> deploy(Web3j web3j, Credentials credentials, ContractGasProvider contractGasProvider) {
        return deployRemoteCall(ReviewManagement.class, web3j, credentials, contractGasProvider, BINARY, "");
    }

    @Deprecated
    public static RemoteCall<ReviewManagement> deploy(Web3j web3j, Credentials credentials, BigInteger gasPrice, BigInteger gasLimit) {
        return deployRemoteCall(ReviewManagement.class, web3j, credentials, gasPrice, gasLimit, BINARY, "");
    }

    public static RemoteCall<ReviewManagement> deploy(Web3j web3j, TransactionManager transactionManager, ContractGasProvider contractGasProvider) {
        return deployRemoteCall(ReviewManagement.class, web3j, transactionManager, contractGasProvider, BINARY, "");
    }

    @Deprecated
    public static RemoteCall<ReviewManagement> deploy(Web3j web3j, TransactionManager transactionManager, BigInteger gasPrice, BigInteger gasLimit) {
        return deployRemoteCall(ReviewManagement.class, web3j, transactionManager, gasPrice, gasLimit, BINARY, "");
    }

    public static class OwnershipTransferredEventResponse extends BaseEventResponse {
        public String previousOwner;

        public String newOwner;
    }
}
